// oplog.go
package controllers_common

import (
	"github.com/martini-contrib/render"
	"martini_template/componnet"
	"martini_template/form"
	"martini_template/models/mongo"
)

type OpLog struct {
}

func (c OpLog) Save(resJson componnet.ResponsJson, r render.Render, lForm form.LogForm) {
	var logModel models_mongo.OpLog
	logModel.OpAction = lForm.OpAction
	logModel.OpContent = lForm.OpContent
	logModel.OperId = lForm.OperId
	logModel.OpIP = lForm.OpIP
	logModel.OpType = lForm.OpType
	logModel.OpTime = lForm.OpTime
	saveRes := logModel.SaveLog()
	if saveRes {
		resJson.SetState(componnet.CODE_SUCC)
		r.JSON(200, resJson)
		return
	} else {
		resJson.SetState(componnet.CODE_FAIL)
		r.JSON(200, resJson)
		return
	}
}
